package com.cisco.pso;

public class FileItem {
	protected String fullName;
	protected String shortName;	
	protected String module;
	
	public FileItem(String fullName, String shortName) {
		this.fullName = fullName;
		this.shortName = shortName;
		
		//parse module
		this.module = fullName.split("/")[2];

	}

	public String getFullName() {
		return fullName;
	}

	public void setFullName(String fullName) {
		this.fullName = fullName;
	}

	public String getShortName() {
		return shortName;
	}

	public void setShortName(String shortName) {
		this.shortName = shortName;
	}

	 
	public String getModule() {
		return module;
	}

	public void setModule(String module) {
		this.module = module;
	}
	
	public String getSubFolder(int depth) {
		String fileName = fullName;

		String path = fileName.substring(0,
				fileName.length() - shortName.length() );

		int lastIndexOfSlash = path.lastIndexOf('/');
		for (int i = 0; i < depth; i++)
			lastIndexOfSlash = path.lastIndexOf('/', lastIndexOfSlash-1);
		String subFolder = path.substring(lastIndexOfSlash+1);
		
		if(subFolder.equals("/"))
			subFolder="";
		
		return subFolder;
	}


	public static void main(String[] args) {
		String fullName = "base/T27L10NSP25/trainingcenter/src/java/com/webex/webapp/trainingcenter/meeting/subaction/MSubActionAA.java";
		String shortName ="MSubActionAA.java";
		
		FileItem item = new FileItem(fullName, shortName);
		System.out.println(item.getModule());		
	}

}
